package com.ysxsoft.wdg.bean.zy;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

public class RuleBean implements Parcelable{

    private String id;
    private String title;
    private String pid;
    private List<SubBean> sub;
    private boolean isSelected;

    protected RuleBean(Parcel in) {
        id = in.readString();
        title = in.readString();
        pid = in.readString();
        sub = in.createTypedArrayList(SubBean.CREATOR);
        isSelected = in.readByte() != 0;
    }

    public static final Creator<RuleBean> CREATOR = new Creator<RuleBean>() {
        @Override
        public RuleBean createFromParcel(Parcel in) {
            return new RuleBean(in);
        }

        @Override
        public RuleBean[] newArray(int size) {
            return new RuleBean[size];
        }
    };

    public boolean isSelected() {
        return isSelected;
    }

    public void setSelected(boolean selected) {
        isSelected = selected;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public List<SubBean> getSub() {
        return sub;
    }

    public void setSub(List<SubBean> sub) {
        this.sub = sub;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(title);
        dest.writeString(pid);
        dest.writeTypedList(sub);
        dest.writeByte((byte) (isSelected ? 1 : 0));
    }

    public static class SubBean implements Parcelable{
        /**
         * id : 2
         * title : 白色
         * pid : 1
         */

        private String id;
        private String title;
        private String pid;
        private String pic;
        private boolean isSelected;
        private boolean iFalse;

        protected SubBean(Parcel in) {
            id = in.readString();
            title = in.readString();
            pid = in.readString();
            pic = in.readString();
            isSelected = in.readByte() != 0;
            iFalse = in.readByte() != 0;
        }

        public static final Creator<SubBean> CREATOR = new Creator<SubBean>() {
            @Override
            public SubBean createFromParcel(Parcel in) {
                return new SubBean(in);
            }

            @Override
            public SubBean[] newArray(int size) {
                return new SubBean[size];
            }
        };

        public boolean isiFalse() {
            return iFalse;
        }

        public void setiFalse(boolean iFalse) {
            this.iFalse = iFalse;
        }

        public boolean isSelected() {
            return isSelected;
        }

        public void setSelected(boolean selected) {
            isSelected = selected;
        }

        public SubBean() {
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getPid() {
            return pid;
        }

        public void setPid(String pid) {
            this.pid = pid;
        }

        public String getPic() {
            return pic == null ? "" : pic;
        }

        public void setPic(String pic) {
            this.pic = pic;
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(id);
            dest.writeString(title);
            dest.writeString(pid);
            dest.writeString(pic);
            dest.writeByte((byte) (isSelected ? 1 : 0));
            dest.writeByte((byte) (iFalse ? 1 : 0));
        }
    }
}

